package com.jdk.juc;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.FutureTask;

public class FutureTaskTest {

    public static ExecutorService executorService = Executors.newFixedThreadPool(10);


    public static void main(String[] args) throws ExecutionException, InterruptedException {
        FutureTask<String> t1 = new FutureTask<String>(()->{
            return "sucess t1";
        });

        FutureTask<String> t2 = new FutureTask<String>(()->{
            return "sucess t2";
        });
        for(int i=0; i< 10; i++) {
            executorService.submit(t1);
            executorService.submit(t2);
            System.out.println(t1.get());
            System.out.println(t2.get());
        }

    }
}
